// ==UserScript==
// @name         继续教育专业课学习平台
// @namespace    http://tampermonkey.net/
// @version      2024-06-11
// @description  try to take over the world!
// @author       1111
// @match        https://jxjy.mynj.cn:8283/rsrczxpx/tec/play/player*
// @match        https://m.mynj.cn:11188/zxpx/tec/play/player*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=mynj.cn
// @updateURL    https://gitee.com/WOAICHIYUZHOU/static-file/raw/master/rsrczxpx.js
// @grant        none
// ==/UserScript==

var started = false;
function getStatus(){
    //真实进展
    setTimeout(getStatus, 3000)
    var p =window.p;
    if($('#realPlayVideoTime') && $('#realPlayVideoTime').length>0){
        var realPre = $('#realPlayVideoTime').html()
        p.play();
        //静音播放
        p.muted(true)
        //console.log(realPre,'realPre')
        var learnProcessOk=p.currentTime()/p.duration()*100 >= realPre;
       // if(learnProcessOk){
       //     p.currentTime(p.duration()*realPre/100)
       // }
        if(realPre >= 100){
            jumpNext();
        }
	}else{
     jumpNext();
    }
}

function jumpNext(){
    //所有课程清单
    var dataLists=$.fn.zTree._z.data.getRoots().content.children;
    //console.log(dataLists,'dataLists')
    // 当前播放的id
    var cwid=$('#contentList').attr('cwid');
    //console.log(cwid,'cwid')
    var toLearnList = dataLists.filter((treeNode) => '1'!=treeNode.playfinished && cwid!=treeNode.cpcwid)
    //console.log(toLearnList,'toLearnList')
    var treeNode = toLearnList[0];
    //console.log(treeNode,'toLearnList')
    window.open(treeNode.url,treeNode.target)
};

(function() {
    //'use strict';

    // Your code here...
   setTimeout(getStatus, 3000)
})();